﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using Dataweb.NShape;
using Dataweb.NShape.WinFormsUI;
using Dataweb.NShape.Advanced;
using Dataweb.NShape.GeneralShapes;
using Dataweb.Utilities;

namespace Dataweb.NShape.GestaultShapes
{
    /// <summary>
    /// Encasulates a glue point for a GComponent
    /// </summary>
    public class GPort : Circle
    {
        Template myTemplate;

        private void setup()
        {
            
        }

        internal static Shape CreateInstance(ShapeType shapeType, Template template)
        {
            return new GPort(shapeType, template);
        }


        public override Shape Clone()
        {
            Shape result = new GPort(Type, (Template)null);
            result.CopyFrom(this);
            return result;
        }

        protected internal GPort(ShapeType shapeType, Template template)
            : base(shapeType, template)
        {
            setup();
        }


        protected internal GPort(ShapeType shapeType, IStyleSet styleSet)
            : base(shapeType, styleSet)
        {
            setup();
        }
    }

    public class GComponent: Box
    {
        private static int PORTSIZE = 20;

        public int inCount = 3;
        public int outCount = 4;

        /// <summary>
        /// Put all common initialization code here.
        /// </summary>
        private void setup()
        {

        }

        internal static Shape CreateInstance(ShapeType shapeType, Template template)
        {
            return new GComponent(shapeType, template);
        }


        public override Shape Clone()
        {
            Shape result = new GComponent(Type, (Template)null);
            result.CopyFrom(this);
            return result;
        }

        protected internal GComponent(ShapeType shapeType, Template template)
            : base(shapeType, template)
        {
            setup();
        }


        protected internal GComponent(ShapeType shapeType, IStyleSet styleSet)
            : base(shapeType, styleSet)
        {
            setup();
        }

        

        
    }

    public static class NShapeLibraryInitializer
    {
        private const string namespaceName = "GestaultShapes";
        private const int preferredRepositoryVersion = 3;

        public static void Initialize(IRegistrar registrar)
        {
            registrar.RegisterLibrary(namespaceName, preferredRepositoryVersion);

            // register GComponent
            //registrar.RegisterShapeType(new ShapeType("GComponent", namespaceName, namespaceName,
            //    delegate(ShapeType shapeType, Template t) { return GComponent.CreateInstance(shapeType, t); }, GComponent.GetPropertyDefinitions));

            registrar.RegisterShapeType(new ShapeType("GComponent", namespaceName, namespaceName,
                GComponent.CreateInstance, GComponent.GetPropertyDefinitions));

            registrar.RegisterShapeType(new ShapeType("GPort", namespaceName, namespaceName,
                GPort.CreateInstance, GPort.GetPropertyDefinitions));
        }
    }
}
